<?php

namespace app\api\controller\group;

use app\api\BaseController;
use app\api\service\GroupGoodsService;

class GoodsController extends BaseController
{

    /**
     *
     * 热门推荐
     * */
    public function hot()
    {
        $store_id = $this->request->param('store_id/d');

        if (empty($store_id)){
            return json(['code' =>0, 'msg' => '非法参数!']);
        }


    }


    /**
     * 根据活动获取拼团商品
     * */
    public function index()
    {
        $group_activity_id = $this->request->param('group_activity_id/d');

        if (empty($group_activity_id)){
            return  json(['code' =>0, 'msg' => '非法参数']);
        }

        $groupGoodsList = GroupGoodsService::getGroupGoodsList($group_activity_id);

        return json(['code' => 1, 'data' => $groupGoodsList,'msg' => '请求成功!']);
    }

    /**
     * 根据获取拼团商品详情
     * */
    public function read()
    {
        $group_goods_id = $this->request->param('group_goods_id/d');

        if (empty($group_goods_id)){
            return  json(['code' =>0, 'msg' => '非法参数']);
        }
        $groupGoods = GroupGoodsService::findGroupGoods($group_goods_id);

        return json(['code' => 1, 'data' => $groupGoods,'msg' => '请求成功!']);
    }
}